﻿<?xml version="1.0" encoding="utf-8"?>
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="Region" type="RegionDefinition" />
  <xs:complexType name="RegionDefinition">
      <xs:choice>
        <xs:element name="Region" type="RegionDefinition" minOccurs="0" maxOccurs="unbounded" />
        <xs:sequence>
          <xs:element name="Where" type="ComplexCondition" minOccurs="0" maxOccurs="1" />
          <xs:element name="OrderBy" type="ArrayOfOrderParameter" minOccurs="0" maxOccurs="1"  />
        </xs:sequence>
      </xs:choice>
    <xs:attribute name="PaddingBefore" type="xs:int" use="optional" />
    <xs:attribute name="PaddingAfter" type="xs:int" use="optional" />
    <xs:attribute name="PaddingBetween" type="xs:int" use="optional" />
    <xs:attribute name="Name" type="xs:string" use="optional" />
    <xs:attribute name="Type" type="RegionType" use="optional" />
  </xs:complexType>
  <xs:complexType name="ArrayOfOrderParameter">
    <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="unbounded" name="Parameter" nillable="true" type="OrderParameter" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="OrderParameter">
    <xs:attribute name="Direction" type="DirectionType" use="optional" />
    <xs:attribute name="Part" type="PartEnum" use="required" />
  </xs:complexType>
  <xs:simpleType name="DirectionType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="Ascending" />
      <xs:enumeration value="Descending" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="PartEnum">
    <xs:restriction base="xs:string">
      <xs:enumeration value="Invalid" />
      <xs:enumeration value="AccessModifier" />
      <xs:enumeration value="EntityType" />
      <xs:enumeration value="Name" />
      <xs:enumeration value="IsStatic" />
      <xs:enumeration value="EntityVariableType" />
      <xs:enumeration value="NumberOfParameters" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="RegionType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="None" />
      <xs:enumeration value="Comment" />
      <xs:enumeration value="Region" />
    </xs:restriction>
  </xs:simpleType>
  <xs:complexType name="ComplexCondition">
    <xs:sequence maxOccurs="unbounded">
      <xs:choice>
        <xs:element name="And" type="ComplexCondition" minOccurs="0" maxOccurs="unbounded"/>
        <xs:element name="Or" type="ComplexCondition" minOccurs="0" maxOccurs="unbounded"/>
        <xs:element name="Condition" type="Condition" minOccurs="0" maxOccurs="unbounded" />
      </xs:choice>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="Condition">
    <xs:attribute name="Part" type="ConditionPartEnum" use="required" />
    <xs:attribute name="Operator" type="OperatorEnum" use="required" />
    <xs:attribute name="Value" type="xs:string" use="required" />
  </xs:complexType>
  <xs:simpleType name="ConditionPartEnum">
    <xs:restriction base="xs:string">
      <xs:enumeration value="Invalid" />
      <xs:enumeration value="AccessModifier" />
      <xs:enumeration value="EntityType" />
      <xs:enumeration value="Name" />
      <xs:enumeration value="IsStatic" />
      <xs:enumeration value="ReturnType" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="OperatorEnum">
    <xs:restriction base="xs:string">
      <xs:enumeration value="Invalid" />
      <xs:enumeration value="Equal" />
      <xs:enumeration value="NotEqual" />
    </xs:restriction>
  </xs:simpleType>
</xs:schema>